package _9ZuHe;

import java.util.List;
import java.util.function.Consumer;

/**
 * @Test: 组合模式 测试
 * @author: ZBoHang
 * @time: 2021/9/7 17:28
 */
class Test {
    public static void main(String[] args) {
        Employee ceo = new Employee("John", "CEO", 3000);

        Employee headSales = new Employee("Robert", "Head Sales", 20000);

        Employee clerk1 = new Employee("Laura", "Marketing", 10000);
        Employee clerk2 = new Employee("Bob", "Marketing", 10000);

        ceo.add(headSales);
        headSales.add(clerk1);
        headSales.add(clerk2);

        List<Employee> subordinates = ceo.getSubordinates();
        subordinates.forEach(employee -> {
            System.out.println(employee.toString());
            if (!employee.getSubordinates().isEmpty()) {
                List<Employee> list = employee.getSubordinates();
                for (Employee e : list) {
                    System.out.println(e.toString());
                }
            }
        });
    }
}
